# THe player of the game

from GameObject import GameObject

class Player(GameObject):
    def move_or_attack(self, dx, dy):
        x = self.x + dx
        y = self.y + dy
        
        target = None
        for game_object in self.gamestate.game_objects:
            if game_object.fighter and game_object.x == x and game_object.y == y:
                target = game_object
                break
            
        if target is not None:
            self.fighter.attack(target)
        else:
            self.move(dx, dy)
            self.gamestate.fov_recompute = True
    